package models

import (
	"time"
)

type Role struct {
	ID        			int       		`gorm:"primary_key"`
	CreatedAt 			time.Time  		`json:"create_time"`
	RoleName 			string 			`gorm:"size:32;not null;unique"`
	RoleMsg  			string 			`gorm:"size:128"`
	Perms				[]Menu			`gorm:"many2many:role_menus"`
	PlatForm			[]ItemPlatfm	`gorm:"many2many:role_platfm"`
}

// User 结构体（实体类）
type User struct {
	ID        			int       			`gorm:"primary_key"`
	CreatedAt 			time.Time  			`json:"create_time"`
	NickName           	string 				`gorm:"size:32"`
	UserName           	string 				`gorm:"size:24"`
	UserPwd            	string
	IsSuper            	bool				`gorm:"force"`
	Status             	int					`gorm:"force"`
	Mobile             	string  			`gorm:"size:32"`
	Email              	string  			`gorm:"size:256"`
	RoleNames	   		string				`gorm:"size:256"`   //用于页面显示使用
	Roles	   		   	[]Role    			`gorm:"many2many:user_roles"` //多对多
}

type Menu struct {
	ID					int 				`gorm:"primary_key"`
	CreatedAt   		time.Time			`json:"create_time"`
	MenuTitle 			string				`gorm:"size:64;not null;unique"`
	MenuUrl				string				`gorm:"size:128"`
	MenuIcon			string				`gorm:"size:64"`
	MenuWeight			int					`gorm:"force"`  //force 强制更新，自定义spop 参考 https://blog.csdn.net/idwtwt/article/details/104018291
	Status				bool				`gorm:"force"`
	IsMenu 				bool				`gorm:"force"`
	PMenu				int					`gorm:"force"`
}

type MenuLevel struct {
	Menu
	CMenus 				[]Menu
}

type MenuLevelAll struct {
	Menu
	MenuLevel 				[]MenuLevel
}


type Dict struct {
	//字典配置
	ID        			uint       		`gorm:"primary_key"`
	CreatedAt 			time.Time  		`json:"create_time"`
	DictKey 			string 			`gorm:"size:64;not null;unique"`
	DictVal  			string 			`gorm:"size:512"`
	DictMsg  			string 			`gorm:"size:255"`
}
